﻿<%@ Page Title="Trips" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Trips.aspx.cs" Inherits="TravelAgency.AspNet.Agents.Trips" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register assembly="Telerik.OpenAccess.Web" namespace="Telerik.OpenAccess" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">    

        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" 
                    Name="Telerik.Web.UI.Common.Core.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" 
                    Name="Telerik.Web.UI.Common.jQuery.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" 
                    Name="Telerik.Web.UI.Common.jQueryInclude.js">
                </asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>      
                <telerik:AjaxSetting AjaxControlID="TripPanel">
                    <UpdatedControls>                        
                        <telerik:AjaxUpdatedControl ControlID="PanelTrips" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="LinkButtonSearch">
                    <UpdatedControls>                        
                        <telerik:AjaxUpdatedControl ControlID="PanelTrips" LoadingPanelID="RadAjaxLoadingPanel1" />                                                                    
                    </UpdatedControls>
                </telerik:AjaxSetting>               
            </AjaxSettings>
        </telerik:RadAjaxManager>
                
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
        </telerik:RadAjaxLoadingPanel>               

        <asp:Panel ID="PanelTrips" runat="server">

                <div class="top-padding">
                    <h2>Trips All Over The World</h2>
                    <asp:Label ID="LabelSearch" runat="server" CssClass="search">
                                            
                        <asp:LinkButton ID="LinkButtonSearch" runat="server" CssClass="button-search" Text="Search" onclick="LinkButtonSearch_Click"></asp:LinkButton>
                        &nbsp;
                        <asp:TextBox ID="TextBoxSearch" runat="server" Width="120px" Height="18px"></asp:TextBox>                                                            
                    </asp:Label>
                </div>

                <telerik:RadListView ID="RadListViewTrips" runat="server" DataSourceID="OpenAccessDataSourceTrips"
                    ItemPlaceholderID="PlaceHolder1" AllowPaging="true" 
                    DataKeyNames="TripId" onitemcommand="RadListViewTrips_ItemCommand">
                    <LayoutTemplate>
                        <div class="trips">
                            <asp:Panel ID="TripPanel" runat="server">
                               
                                <div class="trip">
                                    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                                </div>
                                <div>
                                    <telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="6" Font-Italic="True" BackColor="#FFE9C9" BorderColor="#FFE9C9" BorderStyle="None">
                                        <Fields>
                                            <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                            <telerik:RadDataPagerGoToPageField CurrentPageText="Page" />
                                        </Fields>
                                    </telerik:RadDataPager>
                                </div>
                               
                            </asp:Panel>
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <div class="category">
                            <h3>
                                <%# Server.HtmlEncode(TitleWordWrapEval("title").ToString())%>
                            </h3>
                            <asp:ImageButton ID="SushiImage" runat="server" AlternateText='<%# Server.HtmlEncode(Eval("title").ToString()) %>'
                                Width="120px" Height="80px" CommandName="Select" ImageUrl='<%# "~/Users/DisplayPhoto.ashx?photoId=" + Eval("PhotoId") %>' />
                            <p>
                                <%# Eval("Price", "{0:c}") %>
                            </p>
                            <p>
                                <%# Eval("StartDate", "{0:yyyy.MM.dd}") %> / <%# Eval("EndDate", "{0:yyyy.MM.dd}") %>
                            </p>
                        </div>
                    </ItemTemplate>
                    <SelectedItemTemplate>
                        <div class="trip-selected">
                            <h3>
                                <%# Server.HtmlEncode(TitleWordWrapEval("title").ToString())%>
                            </h3>
                            <asp:Image ID="SushiImage" runat="server" AlternateText='<%# Server.HtmlEncode(Eval("title").ToString()) %>'
                                Width="140px" Height="93px" ImageUrl='<%# "~/Users/DisplayPhoto.ashx?photoId=" + Eval("PhotoId") %>' />
                            <p>
                                <%# Eval("Price", "{0:c}")%>
                            </p>
                            <p>
                                <%# Eval("StartDate", "{0:yyyy.MM.dd}") %> / <%# Eval("EndDate", "{0:yyyy.MM.dd}") %>
                            </p>
                        </div>
                    </SelectedItemTemplate>
                    <EmptyDataTemplate>
                    
                        <asp:Panel ID="PanelTrip" runat="server" CssClass="navigation-header">                     
                            <asp:Panel runat="server" ID="PanelTripDetails">

                                <h2>No trips</h2>

                            </asp:Panel>        
                        </asp:Panel>
                    
                    </EmptyDataTemplate>
                </telerik:RadListView>

            <telerik:OpenAccessDataSource ID="OpenAccessDataSourceTrips" runat="server" 
                ObjectContextProvider="TravelAgency.DAL.TravelAgencyEntities, TravelAgency.DAL" 
                TypeName="TravelAgency.DAL.Trip" Where="StartDate&gt;@DateTimeNow">
                <WhereParameters>
                    <asp:SessionParameter DbType="Date" Name="DateTimeNow" 
                        SessionField="dateTimeNow" />
                </WhereParameters>
            </telerik:OpenAccessDataSource>   
    
            <asp:Panel ID="PanelTrip" runat="server" CssClass="trip-details" Visible="false">
                <h2><asp:Label runat="server" ID="LabelTripNotAvailable" Text="Trip not available"></asp:Label></h2>        
                <asp:Panel runat="server" ID="PanelTripDetails">

                    <h2>Trip details</h2>

                    <div class="trip-title">
                        <b>Title:</b>
                        <asp:Label ID="LabelTitle" runat="server"></asp:Label>
                    </div>
                    <div class="trip-description">
                        <b>Description:</b>
                        <div class="description">
                            <asp:Label ID="LabelDescription" runat="server"></asp:Label>
                        </div>
                        <div>
                            <b>Start date:</b>
                            <asp:Label runat="server" ID="LabelStartDate"></asp:Label>
                        </div>
                        <div>
                            <b>End date:</b>
                            <asp:Label runat="server" ID="LabelEndDate"></asp:Label>
                        </div>
                        <div>
                            <b>Price:</b>
                            <asp:Label runat="server" ID="LabelPrice"></asp:Label>
                        </div>
                        <div>
                            <b>Capacity:</b>
                            <asp:Label runat="server" ID="LabelCapacity"></asp:Label>
                        </div>
                        <div class="link-resevation">
                            <asp:LinkButton ID="LinkButtonReservation" runat="server" 
                                Text="Make reservation" onclick="LinkButtonReservation_Click"></asp:LinkButton>
                        </div>
                    </div>
                </asp:Panel>        
            </asp:Panel>
        
        </asp:Panel>

    <br />

</asp:Content>
